package redis

import (
	"context"
	"github.com/redis/go-redis/v9"
	"log"
	"time"
)

func Running(addr, password string) bool {
	client := redis.NewClient(&redis.Options{
		Addr:        addr,
		Password:    password,
		DialTimeout: 2 * time.Second,
	})
	defer func(client *redis.Client) {
		err := client.Close()
		if err != nil {
			log.Printf("close file failed: %v", err)
		}
	}(client)

	ctx := context.Background()
	_, err := client.Ping(ctx).Result()
	return err == nil
}
